%%This is a very basic article template.
%%There is just one section and two subsections.
\documentclass{article}

\usepackage{tikz}
\pagestyle{empty}
\usetikzlibrary{shapes,positioning}

\begin{document}

\begin{tikzpicture}

\tikzstyle{rect}=[
	draw,
	rectangle,
	minimum width=100pt,
	minimum height=100pt
];
\tikzstyle{circ}=[
	draw,
	circle,
	minimum width=10pt,
	very thick
]
\tikzstyle{circ-2}=[
	circ,
	dashed
]
\node[
	rect	
] (patterns) {};
\node[
	above=0pt of patterns.south
] {patterns};
\node[
	rect,
	right=100pt of patterns
] (queries) {};
\node[
	above=0pt of queries.south
] {queries};
\node[
	circ,
	yshift=30pt,
	xshift=-20pt
] at (queries) (indiv-1) {};
\node[
	circ,
	yshift=20pt,
	xshift=-30pt
] at (patterns) (indiv-1-1) {};

\path[->] (indiv-1) edge (indiv-1-1);
\node[
	circ-2,
	yshift=-4pt,
	xshift=-4pt
] at (indiv-1-1) (indiv-1-1-1) {};
\path[->,dashed] (indiv-1) edge (indiv-1-1-1);
\node[
	circ,
	xshift=20pt,
	yshift=-20pt
] at (queries) (indiv-2) {};
\node[
	circ,
	xshift=30pt,
	yshift=-30pt
] at (patterns) (indiv-2-1) {};
\path[->] (indiv-2) edge (indiv-2-1);
\node[
	circ-2,
	yshift=-4pt,
	xshift=-4pt
] at (indiv-2-1) (indiv-2-1-1) {};
\path[->,dashed] (indiv-2) edge (indiv-2-1-1);
\node[
	below=2pt,
	xshift=8pt
] at (indiv-1) {$q_1$};
\node[
	below=2pt,
	xshift=8pt
] at (indiv-2) {$q_2$};
\node[
	below=2pt,
	xshift=8pt
] at (indiv-1-1) {$p_1$};
\node[
	below=2pt,
	xshift=8pt
] at (indiv-2-1) {$p_2$};
\node[
	circ,
	xshift=-30pt
] at (queries) (indiv-3) {};
\node[
	circ,
	xshift=-45pt,
	yshift=-10pt
] at (patterns) (indiv-3-1) {};
\path[->] (indiv-3) edge (indiv-3-1);
\node[
	circ-2,
	yshift=-4pt,
	xshift=-4pt
] at (indiv-3-1) (indiv-3-1-1) {};
\path[->,dashed] (indiv-3) edge (indiv-3-1-1);
\node[
	below=2pt,
	xshift=8pt
] at (indiv-3) {$q_3$};
\node[
	below=2pt,
	xshift=8pt
] at (indiv-3-1) {$p_3$};
\node[
	above=2pt,
	xshift=-8pt
] at (indiv-1-1-1) {$p_1^\prime$};
\node[
	above=2pt,
	xshift=-8pt
] at (indiv-2-1-1) {$p_2^\prime$};
\node[
	above=2pt,
	xshift=-8pt
] at (indiv-3-1-1) {$p_3^\prime$};

\end{tikzpicture}

\end{document}
